package es.nadalgoyo.frikiquest;

import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import es.nadalgoyo.frikiquest.control.PreguntaControl;
import es.nadalgoyo.frikiquest.util.Util;
import es.nadalgoyo.frikiquest.R;

public class ImageActivity extends FrikiTrivialActivity {

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.image);

		snd = getSoundPlayerNewInstance(R.raw.saberup);
		snd.play();

		Bundle bundle = getIntent().getExtras();
		byte[] imagen = bundle.getByteArray(PreguntaControl.IMAGEN);

		ImageView img = (ImageView) findViewById(R.id.Imagen);
		img.setImageBitmap(BitmapFactory.decodeByteArray(imagen, 0,
				imagen.length));
		img.setMaxHeight(400);
		img.setMaxWidth(400);

		img.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				try {
					ImageActivity.this.finish();
				} catch (Throwable e) {
					e.printStackTrace();
					Util.showErrorMensaje(ImageActivity.this, e.getMessage(),
							true);
				}

			}
		});
	}
}